package com.gml.jdk.jvm;

import com.sun.crypto.provider.DESKeyFactory;
import sun.misc.Launcher;

import java.net.URL;

public class TestJdkClassLoader {

    public static void main(String[] args) {
        System.out.println("bootstrapClassLoader:" + String.class.getClassLoader());
        System.out.println("extClassLoader:" + DESKeyFactory.class.getClassLoader());
        System.out.println("appClassLoader:" + TestJdkClassLoader.class.getClassLoader());

        System.out.println("==============================");

        ClassLoader appClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extClassLoader = appClassLoader.getParent();
        ClassLoader bootstapClassLoader = extClassLoader.getParent();

        System.out.println("appClassLoader:" + appClassLoader);
        System.out.println("extClassLoader:" + extClassLoader);
        System.out.println("bootstapClassLoader:" + bootstapClassLoader);

        System.out.println("==============================");

        System.out.println("bootstrapClassLoader加载以下的文件：");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        for (URL urL : urLs) {
            System.out.println(urL);
        }

        System.out.println("==============================");
        System.out.println("extClassLoader加载以下的文件：");
        System.out.println(System.getProperty("java.ext.dirs"));

        System.out.println("==============================");
        System.out.println("appClassLoader加载以下的文件：");
        System.out.println(System.getProperty("java.class.path"));
    }

}
